<?php
namespace Framework;

class Validation {
    /**
     * Validate if the string length is within the specified range.
     * @param string $value The value to be validated.
     * @param integer $min The minimum length.
     * @param int $max The maximum length.
     * @return bool Returns true if the string length is within range, false otherwise.
     */
    public static function string($value, $min = 1, $max = INF) {
        if (is_string($value)) {
            $value = trim($value);
            $length = strlen($value);
            return $length >= $min && $length <= $max;
        }
        return false;
    }

    /**
     * Validate an email address.
     * @param string $value The email to be validated.
     * @return bool Returns true if the email is valid, false otherwise.
     */
    public static function email($value) {
        $value = trim($value);
        return filter_var($value, FILTER_VALIDATE_EMAIL);
    }

    /**
     * Check if two values match.
     * @param string $value1 The first value.
     * @param string $value2 The second value.
     * @return bool Returns true if both values match, false otherwise.
     */
    public static function match($value1, $value2) {
        $value1 = trim($value1);
        $value2 = trim($value2);
        return $value1 === $value2;
    }
}